"""

@name:python学习
@author:yuki
@projectname:起步

"""
### part1
import re

username = ["sdafweuirhi314!@#1","asdh23___!24","asd124_1235a"]
def fun1(item):
    if re.findall(r"^[A-Za-z][A-Za-z0-9_]{5-17}$",item):
        return f"{item} is right"
    else:
        return f"{item} is error"
print(list(map(fun1,username)))

###  filter显示
username = ["sdafweuirhi314!@#1","asdh23___!24","asd124_1235a"]
print(list(filter(lambda x:re.findall(r"^[A-Za-z][A-Za-z0-9_]{5-17}$",x),username)))

### reduce

import functools
print(functools.reduce(lambda x, y: x * y, range(1, 6)))


## filter
print(list(filter(lambda x:x%3==0,range(1,101))))

## map
print(list(map(lambda x:x*x,range(1,11))))

##lst

lst = [1,4,5,9]
print(str(functools.reduce(lambda x,y:x*10+y,lst)))


#### part 2
lst1 = [7,-8,5,4,0,-2,-5]
print(max(lst1))
print(sorted(lst1, key=lambda x:(x<=0,abs(x))))
# def fuc1(x):
#     return max(lst1)+1 -x if x<=0 else x
# print(sorted(lst1,key=fuc1))



###### part3
s = "asdf1234IJFIS45"
def func2(x):
    return (x.isdigit(),x.isupper(),x.isdigit() and int(x)%2 == 0,x)
print(sorted(s,key=func2))